<?php
$this->widget('ext.pagetitle.PageTitle',array(
	'parts'=>array(
		CHtml::encode($model->name),
		CHtml::encode($model->contest->name),
		CHtml::encode(Yii::app()->name),
	),
));

$this->breadcrumbs=array(
	$model->contest->name=>array('contest/view','id'=>$model->contestId),
	CHtml::encode($model->name),
);

Yii::app()->clientScript->registerScript('CommentCreateButton',"
	$('#commentCreateButton').click(function() {
		window.location.hash = 'comment-create';
		$('#Comment_alias').focus();
		return false;
	});
")
?>

<div class="entry-view">

	<div class="top clearfix">
		<div class="title float-left">
			<h1><?php echo CHtml::encode($model->name); ?></h1>
		</div>
		<div class="back float-right">
			<?php echo CHtml::link(Yii::t('frontend','RETURN TO THE CONTEST'),array('contest/view','id'=>$model->contestId),
			           array('class'=>'btn')); ?>
		</div>
	</div>

	<div class="image">
		<?php $model->renderImage(IMAGE_VERSION_LARGE,$model->name); ?>
		<div class="previous">
			<?php if ($prevId !== null): ?>
				<?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/arrow-left.png',Yii::t('frontend','Previous'),
						array('class'=>'twipsify','title'=>Yii::t('frontend','Previous'))),array('entry/view','id'=>$prevId)); ?>
			<?php endif; ?>
		</div>
		<div class="next">
			<?php if ($nextId !== null): ?>
				<?php echo CHtml::link(CHtml::image(Yii::app()->request->baseUrl.'/images/arrow-right.png',Yii::t('frontend','Next'),
						array('class'=>'twipsify','title'=>Yii::t('frontend','Next'))),array('entry/view','id'=>$nextId)); ?>
			<?php endif; ?>
		</div>
		<div class="vote-count">
			<strong><?php echo $model->getVotesString(); ?></strong>
		</div>
	</div>

	<div class="social clearfix">

		<div class="like float-left">
			<fb:like href="<?php echo Yii::app()->createAbsoluteUrl('entry/view',array('id'=>$model->id)); ?>" send="true" layout="standard" width="450" show_faces="false" action="recommend" font="arial"></fb:like>
		</div>

		<div class="votes float-right">
			<?php $this->renderPartial('_voteButton',array('model'=>$model)); ?>
		</div>
		
	</div>

	<a name="comments"></a>
	<div class="comments">
		<h2><?php echo Yii::t('frontend', 'Comments'); ?></h2>

		<?php if (!Yii::app()->user->isGuest): ?>
			<div class="add-link">
				<?php echo CHtml::link(Yii::t('frontend','ADD A COMMENT'),'',array(
					'id'=>'commentCreateButton',
					'class'=>'btn primary large',
				)); ?>
			</div>
		<?php endif; ?>

		<div class="list">
			<?php $this->widget('BootstrapListView', array(
				'dataProvider'=>$comments,
				'itemView'=>'/comment/_view',
				'template'=>'{sorter} {items} {pager}',
				'emptyText'=>Yii::t('frontend', 'No comments have been submitted for this entry.'),
				'viewData'=>array('entry'=>$model,'count'=>$comments->getItemCount()),
				'afterAjaxUpdate'=>"js:function(id,data) {
					jQuery('.twipsify').bootstraptwipsy();
				}",
				'sortableAttributes'=>array(
					'created',
					'ups',
				),
			)); ?>
		</div>

	</div>

	<?php if (!Yii::app()->user->isGuest): ?>
		<a name="comment-create"></a>
		<div class="comment-create">
			<?php echo $this->renderPartial('/comment/_form', array(
			    'model'=>$comment,
			    'entry'=>$model,
			    'legend'=>Yii::t('frontend', 'Create a new comment'),
				'displayResetButton'=>true,
			)); ?>
		</div>
	<?php endif ;?>

</div>